Reference
  Area\Util.txt
  Util\Audio.txt
  Util\Party.txt
  Area\Service.txt
  Util\CommonDialog.txt
End Reference

Procedure Main(startAt)

  Dim ac = Nothing

  RegisterCommonEventHandlers()

  SetZoneOfTown(48, 48, 1, 1, 46, 46, ExitArea_Enter)

  ac = AddActor_MTStopped("EqShopper", 34, 40, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("EqShopperEve", 34, 41, 10, [A_Null], EqShopperEve_Contact)

  ac = AddActor_MTStopped("MgShopper", 36, 40, 0, [A_OldMan], ActorMotion.Down, Nothing)
  ac = AddStaticActor("MgShopperEve", 36, 41, 10, [A_Null], MgShopperEve_Contact)

  ac = AddActor_MTStopped("GdShopper", 29, 29, 0, [A_Woman], ActorMotion.Down, Nothing)
  ac = AddStaticActor("GdShopperEve", 29, 30, 10, [A_Null], GdShopperEve_Contact)

  ac = AddActor_MTStopped("InnFront", 27, 29, 0, [A_Man], ActorMotion.Down, Nothing)
  ac = AddStaticActor("InnFrontEve", 27, 30, 10, [A_Null], InnFrontEve_Contact)
    
  ac = AddActor_MTZonedRandom("Historian", 6, 6, 0, _
    3, 4, 0, 9, 8, 0, [A_Father], Historian_Contact)
    
  ac = AddActor_MTZonedRandom("Celine", 30, 6, 0, _
    27, 4, 0, 33, 8, 0, [A_Woman], Celine_Contact)
    
  ac = AddActor_MTZonedRandom("Towner1", 6, 17, 0, _
    3, 15, 0, 9, 19, 0, [A_Man], Towner1_Contact)
    
  ac = AddActor_MTZonedRandom("Towner2", 30, 17, 0, _
    27, 15, 0, 33, 19, 0, [A_OldMan], Towner2_Contact)
    
  DoInsideWarp(startAt, SetEntranceEx({24, 1, 0}, {24, 46, 0}, {1, 12, 0}, {46, 35, 0}), False)
  
  ChangeBGM(Music.Town)
  PutAreaNameLabel()

  NotifyEntered()
  Idle(ProcessInput)
  NotifyExiting()

End Procedure

Procedure ExitArea_Enter()
  BeginOutsideWarp([Field], GetAreaObject().Tag)
End Procedure

Procedure EqShopperEve_Contact()
  DoShop({[SteelSword], [BastardSword], [IronArmor], [SteelArmor], [IronShield], [SteelShield], [IronHelmet], [SteelHelmet]})
End Procedure

Procedure MgShopperEve_Contact()
  DoMagicShop({[Heal2], [Fire2], [Cold2], [Confuse], [PhysDPUp], [PhysDPDown], [HealAll1], [Revive1], [Elec2], [StrUp], [StrDown], [ColdDPUp]})
End Procedure

Procedure GdShopperEve_Contact()
  DoShop({[Heal_T1], [Heal_T2], [CureAll_T], [Revive_T]})
End Procedure

Procedure InnFrontEve_Contact()
  DoInn(60)
End Procedure

Procedure Towner1_Contact()
  DoMsg("ううむ難解だ　今年のダービーは……")
End Procedure

Procedure Towner2_Contact()
  DoMsg("神はこの世界をお造りになられた時", _
    "サイコロをお振りになったのじゃ")
  Sleep(500)
  DoMsg("何の意味か分からぬ？", _
    "まあ　お気になさるな", _
    "プレイには関係ない事じゃて")
End Procedure

Procedure Historian_Contact()
  Dim q_name = "古代史研究者："
  If DoYesNoMsg(q_name, "私は古代史の研究をしている者だ", _
    "最新の成果を聞きたいか？") = True Then
    DoMsg(q_name, "昔　邪悪な魔道士が危険な魔法を作った", _
      "敵を内部より破壊するというものだ", _
      "", _
      "効くかどうかは場合によるが", _
      "効けば相手はほぼ即死するという")
    DoMsg(q_name, "魔道士はその魔法を２冊の書に記した", _
      "死後　書の一方は別の魔道士が保管することになり", _
      "もう一方はどこかに封印されたらしい")
    DoMsg(q_name, "だが　その別の魔道士も死んだあと", _
      "書がどこへ行ったのか　誰も知らないのだ")
  End If
End Procedure

Procedure Celine_Contact()
  Dim p_name = [TheHero].Name + "："
  Dim q_name = "セリーヌ："
  If TestFlag("Menom_3") Then
    DoMsg(q_name, "大変お世話になりました")
  ElseIf TakeOurTool([GoldenBarrette]) Then
    DoMsg(q_name, "手紙を届けてくれたのですね", _
      "ありがとうございます")
    DoMsg(p_name, "ご主人からこれを預かっています")
    DoMsg(q_name, "まあ！　綺麗な髪飾り")
    DoMsg(p_name, "あと　スイレンの咲く頃に帰る　と", _
      "伝えてくれとおっしゃっていましたよ")
    DoMsg(q_name, "そうですか……待ち遠しいわ", _
      "ああ　ジェレミー　早く帰ってきて……")
    SetFlag("Menom_3")
  ElseIf TestFlag("Menom_2") Then
    DoMsg(q_name, "ありがとうございました")
  ElseIf TestFlag("Pinema_1") Then
    DoMsg(q_name, "手紙を届けてくれたのですね", _
      "ありがとうございます")
    DoMsg(p_name, "元気にやってる　と", _
      "伝えてほしいとのことです")
    DoMsg(q_name, "そうですか……", _
      "それならばよいのですが")
    SetFlag("Menom_2")
  ElseIf TestFlag("Menom_1") Then
    DoMsg(q_name, "よろしくお願いします")
  Else
    DoMsg(q_name, "旅のお方ですか？")
    DoMsg(p_name, "はい")
    DoMsg(q_name, "アドルニアのピネマ鉱山に", _
      "行く事がありますでしょうか")
    DoMsg(p_name, "そのうち行くと思います")
    If DoYesNoMsg(q_name, "ならばお願いがございます", _
      "この手紙を主人に渡して頂けないでしょうか") Then
      DoMsg(q_name, "ありがとうございます", _
        "すみませんが　よろしくお願いします")
      Sleep(500)
      DoMsg(p_name, "ご主人のお名前はジェレミーさんですか")
      DoMsg(q_name, "はい　そうです　私はセリーヌ", _
        "そろそろ帰ってくるはずの時期なのに", _
        "帰ってこないので　とっても心配なんです")
      GiveUsTool([LoveLetter])
      SetFlag("Menom_1")
    Else
      DoMsg(q_name, "そうですか……")
    End If
  End If
End Procedure
